﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace NextAction.Domain.Abstract
{
    public enum PriorityEnum
    {
        Undefined = 0,
        Normal = 1,
        Medium = 2,
        High = 3
    }

    public abstract class GtdEntity
    {
        public GtdEntity()
        {
            PriorityID = 1;
        }

        public bool IsCompleted { get; set; }

        [Required(ErrorMessage = "Please enter a name")]
        public string Name { get; set; }

        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        public int UserID { get; set; }

        [Required]
        public int PriorityID { get; set; }

        [NotMapped]
        public PriorityEnum Priority
        {
            get { return (PriorityEnum)PriorityID; }
            set { PriorityID = (int)value; }
        } 

        public virtual void CopyFrom(GtdEntity entity)
        {
            this.IsCompleted = entity.IsCompleted;
            this.Name = entity.Name;
            this.Description = entity.Description;
            this.UserID = entity.UserID;
            this.PriorityID = entity.PriorityID;
        }

        public void CopyTo(GtdEntity entity)
        {
            entity.CopyFrom(this);
        }
    }
}
